import { imgurl,urls } from '@/utils/constant.js';
	import { getservicedetail} from '@/api/api.js'
	export default {
		data() {
			return {
				info: null
			}
		},
		computed: {
			list() {
				if (this.info) {
					return this.info['bannerimages']
				}
				return []
			},
			contentStyle() {
				if (this.info && this.info.specification && this.info.specification.length) {
					return {
						color: this.info.specification[0].intro
					}
				}
				return {color: 'inherit'}
			}
		},
		onLoad(props) {
			props.id && this.getservicedetail(props.id);
		},
		onReachBottom() {
			// console.log('onReachBottom-----------')
			uni.$emit('onReachBottom');
		},
		methods: {
			async getservicedetail(id) {
				const ret = await getservicedetail(id);
	
				if (ret && ret.data) {
					this.info = ret.data.map(row => {
						let bannerimages = [];
						if (row.bannerimages) {
							bannerimages = row.bannerimages.split(',').map(imgPath => urls.requestURL + '/' + imgPath)
						}
						let specification;
						try {
							specification =  JSON.parse(row.specificationsjson);
						} catch(err) {}
						return {
							id: row.id,
							bannerimages,
							name: row.cname,
							content: row.content.replace(/<img/gi, '<img style="width:100%;height:auto;display:block;" '),
							describe: row.describe,
							specification,
						}
					})[0];
				}
			}
		}
	}